precision highp float;

uniform sampler2D u_tex;

varying vec2 v_uv0;
varying vec2 v_uv[8];

const vec4 c_weights = vec4(0.14489292176612587, 0.12264921034103102, 0.09290249985875561, 0.06297020422491453);


vec4 texture2Dmirror (sampler2D tex, vec2 uv) {
    uv = mod(uv, 2.0);
    uv = mix(uv, 2.0 - uv, step(vec2(1.0), uv));
    return texture2D(tex, fract(uv));
}
vec4 texture2Dclamp (sampler2D tex, vec2 uv) {
    vec4 color = texture2D(tex, uv);
    uv = step(vec2(0.0), uv) * step(uv, vec2(1.0));
    return color * uv[0] * uv[1];
}

void main () {
    vec4 sum = texture2D(u_tex, v_uv0) * 0.153170327618346;
	for (int i = 0; i < 4; ++i) {
		sum += texture2D(u_tex, v_uv[i * 2 + 0]) * c_weights[i];
		sum += texture2D(u_tex, v_uv[i * 2 + 1]) * c_weights[i];
	}
	gl_FragColor = sum;
}